import React from 'react'
import ReactDOM from 'react-dom/client'
import Popup from './popup/index.tsx'
import '@/styles/index.scss'

const isDev = import.meta.env.VITE_PROJECT_ENV !== 'production'
const port = import.meta.env.VITE_HMR_PORT;
if (isDev) {
  const ws = new WebSocket('ws://localhost:' + port)
  ws.onmessage = event => {
    if (event.data === 'reload-app') {
      chrome.runtime.reload()
    }

    if (event.data === 'reload-window') {
      window.location.reload()
    }
  }
}

ReactDOM.createRoot(document.getElementById('root')!).render(
  <React.StrictMode>
    <Popup />
  </React.StrictMode>,
)
